const path = require("path")
const DllPlugin = require("webpack/lib/DllPlugin");

const resolve = filePath => path.resolve(__dirname, '../', filePath)

module.exports = {
    mode: "production",
    entry: {
        vendor: [
            // "react",
            // "react-dom",
            // "file-saver",
            // "exceljs",
            // "jszip",
            "plain-design-composition",
            "plain-design",
            // "markdown-it",
            // "markdown-it-container",
            // "markdown-it-emoji",
            // "monaco-editor",
        ],
    },
    resolve: {
        alias: {}
    },
    externals: {
        react: {
            root: 'React',
            commonjs: 'react',
            commonjs2: 'react',
        },
        'react-dom': {
            root: 'ReactDOM',
            commonjs: 'react-dom',
            commonjs2: 'react-dom',
        },
    },
    output: {
        path: resolve('dll'),
        filename: "dll-[name].[hash:8].min.js", //react.dll.js
        library: "_dll_[name]",

        libraryTarget: 'umd',
        globalObject: 'this'
    },
    plugins: [
        new DllPlugin({
            name: "_dll_[name]",
            path: resolve("dll/dll-[name].manifest.json"),
        }),
    ],
    module: {
        rules: [
            {
                test: /\.(t|j)sx?$/,
                loader: 'babel-loader',
                exclude: /node_modules(?!.*(plain-utils|plain-loading|plain-popper).*)/,
            },
        ]
    }
};
